
import { useImmer } from "use-immer"
import { enableMapSet } from 'immer';
import { createContainer } from "unstated-next"
import { useEffect} from "react"
import {setConnectIcon} from "./utils"

enableMapSet();
import {IStore} from "./type"
function useStore(initialState:IStore={vip:false,nodesChanged:false,shopChanged:false,userInfo:{},Email:"",isLogin:false,connected:false,currentLine:{},lineData:[],shopList:[]}){
    const [store,setStore] = useImmer<IStore>(initialState)
 
    useEffect(()=>{
        setConnectIcon(store.connected)
    },[store.connected])

    return {store,setStore}
}

export default createContainer(useStore)